home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacGambit 2.0 / sources1 / Runtime (.c & .h) / os_mac_eStyle.c < prev    next >
Encoding:
Text File  |  1992-12-03  |  21.7 KB  |  607 lines  |  [TEXT/KAHL]

  1. /* os_mac_eStyle.c
  2.  * 2Jun92  e
  3.  */
  4.  
  5. #include <Dialogs.h>
  6. #include <Controls.h>
  7. #include <QuickDraw.h>
  8. #include <Windows.h>
  9. #include <ToolUtils.h>
  10. #include <OSUtils.h>
  11. #include <Menus.h>
  12. #include <Fonts.h>
  13. #include <resources.h>
  14.  
  15. #include "os_mac.h"
  16.  
  17. /* extensions to an editor for text files by e
  18.    questions/comments via Internet <e@Flavors.COM>
  19. */
  20. /* Copyright © e 1992. All rights reserved.
  21.     Developed using THINK C 5.0.1 for use with Gambit Scheme.
  22.     This code may be freely distributed as long as this noti DrawPopUpX( popMenu2, &popUpBox2, fontChoice2 );
  23. }
  24.  
  25. /* BorderDefault draws a heavy border around the default ( OK ) button */
  26. static pascal void BorderDefault( WindowPtr dwind, short dinum )
  27. { short itemtype;
  28.   Handle itemhandle;
  29.   Rect borderRect;
  30.   GetDItem( dwind, esdOK, &itemtype, &itemhandle, &borderRect );
  31.   InsetRect( &borderRect, -4, -4 );
  32.   PenSize( 3, 3 );
  33.   FrameRoundRect( &borderRect, 16, 16 );
  34.   PenSize( 1, 1 );
  35. }
  36.  
  37. /* Outliner draws a light border around the the user item */
  38. static pascal void Outliner( WindowPtr dwind, short dinum )
  39. { short itemtype;
  40.   Handle itemhandle;
  41.   Rect borderRect;
  42.   GetDItem( dwind, dinum, &itemtype, &itemhandle, &borderRect );
  43.   /* InsetRect( &borderRect, -4, -4 ); */
  44.   PenSize( 1, 1 );
  45.   FrameRoundRect( &borderRect, 16, 16 );
  46. }
  47.  
  48. /* util fcns. */
  49.  
  50. /* cursor to IBeam if it's over an active edit line, arrow if it's not */
  51. void IBeamIt( WindowPtr dwind )
  52. { Point mouseAt;
  53.   short itemtype;
  54.   Handle itemhandle;
  55.   Rect borderRect;
  56.   short itemNum;
  57.   /* first get the current edit line out of the dialog record */
  58.   itemNum = ((DialogPeek )dwind)->editField + 1; /* always stored 1 less */
  59.   GetDItem( dwind, itemNum, &itemtype, &itemhandle, &borderRect );
  60.   GetMouse( &mouseAt );
  61.   if( PtInRect( mouseAt, &borderRect ) )
  62.     SetCursor(&ibeam_cursor);
  63.   else
  64.     SetCursor(&arrow);
  65. }
  66.  
  67. static void pseudoClick( DialogPtr dbox, short item )
  68. { short itemtype;
  69.   Rect itemrect;
  70.   Handle hC;
  71.   long tilticks;
  72.   GetDItem( dbox, item, &itemtype, &hC, &itemrect );
  73.   HiliteControl( (ControlHandle)hC, inButton );
  74.   Delay( 8, &tilticks );
  75.   HiliteControl( (ControlHandle)hC, false );
  76. }
  77.  
  78. static short apndMenu( MenuHandle hM, Str255 title, short itemno, Boolean check, Boolean realfont )
  79. {
  80.   AppendMenu( hM, title );
  81.   if( realfont ) SetItemStyle( hM, itemno, outline );
  82.   if( check )
  83.   { SetItemMark( hM, itemno, checkMark );
  84.     return itemno;
  85.   }
  86.   return 0;
  87. }
  88.  
  89. static MenuHandle sizeMenu( short id, short *ckitem, short fNum, short curSize )
  90. { MenuHandle hM;
  91.   Str255 oddSize;
  92.   short match = 0;
  93.   hM = NewMenu( id, "" );
  94.   match |= apndMenu( hM,  "\p9", 1, (curSize ==  9), RealFont( fNum,  9 ) );
  95.   match |= apndMenu( hM, "\p10", 2, (curSize == 10), RealFont( fNum, 10 ) );
  96.   match |= apndMenu( hM, "\p12", 3, (curSize == 12), RealFont( fNum, 12 ) );
  97.   match |= apndMenu( hM, "\p14", 4, (curSize == 14), RealFont( fNum, 14 ) );
  98.   match |= apndMenu( hM, "\p18", 5, (curSize == 18), RealFont( fNum, 18 ) );
  99.   match |= apndMenu( hM, "\p24", 6, (curSize == 24), RealFont( fNum, 24 ) );
  100.   if( match == 0 )
  101.   { NumToString( (long )curSize, oddSize );
  102.     InsMenuItem( hM, oddSize, 0 );
  103.     InsMenuItem( hM, "\p(-", 1 );
  104.     SetItemMark( hM, 1, checkMark );
  105.     if( RealFont( fNum, curSize ) ) SetItemStyle( hM, 1, outline );
  106.     *ckitem = 1;
  107.   }
  108.   else *ckitem = match;
  109.   return( hM );
  110. }
  111.  
  112. static short doPop( DialogPtr esd, MenuHandle popMenu, Rect popUpBox, short id, short oldChoice )
  113. { long chosen;
  114.   Point popLoc;
  115.   short newChoice;
  116.   InsertMenu( popMenu, -1 );
  117.   popLoc = topLeft(popUpBox);
  118.   LocalToGlobal( &popLoc );
  119.   CalcMenuSize( popMenu ); /* Work around Menu Mgr bug */
  120.   chosen = PopUpMenuSelect( popMenu, popLoc.v, popLoc.h, oldChoice );
  121.   DeleteMenu( id );
  122.   if( chosen != 0 )
  123.   { newChoice = LoWord(chosen);
  124.     if( newChoice != oldChoice )
  125.     { SetItemMark( popMenu, oldChoice, ' ' );
  126.       SetItemMark( popMenu, newChoice, checkMark );
  127.       EraseRect( &popUpBox );
  128.       return( newChoice );
  129.     }
  130.   }
  131.   return 0;
  132. }
  133.  
  134. /* filter proc */
  135.  
  136. #define kReturnKey 0x0D
  137. #define kEnterKey 0x03
  138. #define kEscKey 0x1B
  139. #define kTabKey 9
  140. enum  {
  141.     kBackSpace = 8,
  142.     kLeftArrow = 0x1C, kRightArrow, kUpArrow, kDownArrow,
  143.     kDeleteKey = 0x7F
  144. };
  145.  
  146. /* size menu selection => edit text box */
  147. static void doSize1( DialogPtr esd )
  148. { Rect tempRect;
  149.   short tempItem;
  150.   Handle tempHandle;
  151.   long tmp;
  152.   Str255 tStr;
  153.   GetDItem( esd, esdSize1Et, &tempItem, &tempHandle, &tempRect );
  154.   GetItem( popMenu3, sizeChoice3, tStr );
  155.   SetIText( tempHandle, tStr );
  156.   SelIText( esd, esdSize1Et, 0, 32767 );
  157.   StringToNum( tStr, &tmp);
  158.   tsNewPri.tsSize = tmp;
  159. }
  160.  
  161. /* size menu selection => edit text box */
  162. static void doSize2( DialogPtr esd )
  163. { Rect tempRect;
  164.   short tempItem;
  165.   Handle tempHandle;
  166.   long tmp;
  167.   Str255 tStr;
  168.   GetDItem( esd, esdSize2Et, &tempItem, &tempHandle, &tempRect );
  169.   GetItem( popMenu4, sizeChoice4, tStr );
  170.   SetIText( tempHandle, tStr );
  171.   SelIText( esd, esdSize2Et, 0, 32767 );
  172.   StringToNum( tStr, &tmp);
  173.   tsNewAlt.tsSize = tmp;
  174. }
  175.  
  176. /* font menu selection triggers update of size menu */
  177. static void doFont1( void )
  178. { Str255 tStr;
  179.   GetItem( popMenu1, fontChoice1, tStr );
  180.   GetFNum( tStr, &tsNewPri.tsFont );
  181.   if( popMenu3 ) DisposHandle( popMenu3 );
  182.   popMenu3 = sizeMenu( popMenuID3, &sizeChoice3, tsNewPri.tsFont, tsNewPri.tsSize );
  183. }
  184.  
  185. /* font menu selection triggers update of size menu */
  186. static void doFont2( void )
  187. { Str255 tStr;
  188.   GetItem( popMenu2, fontChoice2, tStr );
  189.   GetFNum( tStr, &tsNewAlt.tsFont );
  190.   if( popMenu4 ) DisposHandle( popMenu4 );
  191.   popMenu4 = sizeMenu( popMenuID4, &sizeChoice4, tsNewAlt.tsFont, tsNewAlt.tsSize );
  192. }
  193.  
  194. /* this function always returns a value between 1 and MAXFONTSIZE inclusive */
  195. /* an out of range number returns 8;
  196.    this is so font sizes and tab stops are reasonable */
  197. static long etToNum( DialogPtr dbox, short item )
  198. { short tempItem;
  199.   Rect tempRect;
  200.   Handle tempHandle;
  201.   long tmp;
  202.   Str255 tStr;
  203.   GetDItem( dbox, item, &tempItem, &tempHandle, &tempRect );
  204.   GetIText( tempHandle, tStr );
  205.   StringToNum( tStr, &tmp);
  206.   if( tmp > MAXFONTSIZE || tmp < 1 ) tmp = 8;
  207.   return tmp;
  208. }
  209.  
  210. /* update size menu if size edit text box changed */
  211. static void preSize1( DialogPtr esd )
  212. { long tmp;
  213.   tmp = etToNum( esd, esdSize1Et );
  214.   if( tsNewPri.tsSize != tmp )
  215.   { tsNewPri.tsSize = tmp;
  216.     if( popMenu3 ) DisposHandle( popMenu3 );
  217.     popMenu3 = sizeMenu( popMenuID3, &sizeChoice3, tsNewPri.tsFont, tsNewPri.tsSize );
  218.   }
  219. }
  220.  
  221. /* update size menu if size edit text box changed */
  222. static void preSize2( DialogPtr esd )
  223. { long tmp;
  224.   tmp = etToNum( esd, esdSize2Et );
  225.   if( tsNewAlt.tsSize != tmp )
  226.   { tsNewAlt.tsSize = tmp;
  227.     if( popMenu4 ) DisposHandle( popMenu4 );
  228.     popMenu4 = sizeMenu( popMenuID4, &sizeChoice4, tsNewAlt.tsFont, tsNewAlt.tsSize );
  229.   }
  230. }
  231.  
  232. pascal Boolean filterIt( DialogPtr esd, EventRecord *myDialogEvent, short *theDialogItem)
  233. { WindowPtr temp;
  234.   char theKey;
  235.   Rect tempRect;
  236.   short tempItem;
  237.   Handle tempHandle;
  238.   Boolean result = false;
  239.  
  240.   GetPort( &temp );
  241.   SetPort( esd );
  242.     
  243.   IBeamIt( esd ); /* make IBeam cursor when over the active edit line */
  244.     
  245.   /* do standard filtering for escape and return as OK and Cancel aliases */
  246.   /* invert the button in the dialog, so the user get's visual feedback */
  247.  
  248.   if ((myDialogEvent->what == keyDown) || (myDialogEvent->what == autoKey))
  249.   { theKey = myDialogEvent->message & charCodeMask;
  250.     if( (myDialogEvent->modifiers & (cmdKey|controlKey|optionKey)) == 0 )
  251.     { switch( theKey )
  252.       { case kReturnKey:
  253.         case kEnterKey:
  254.             *theDialogItem = esdOK;
  255.             pseudoClick( esd, esdOK );
  256.           SetPort(temp);
  257.           result = true;
  258.           break;
  259.         case kEscKey:
  260.           *theDialogItem = esdCancel;
  261.           pseudoClick( esd, esdCancel );
  262.           SetPort(temp);
  263.           result = true;
  264.           break;
  265.         case kTabKey:
  266.         case kBackSpace:
  267.         case kLeftArrow:
  268.         case kRightArrow:
  269.         case kUpArrow:
  270.         case kDownArrow:
  271.         case kDeleteKey:
  272.             break;
  273.         default:
  274.           /* filter out non-numeric keys */
  275.           if( theKey < 0x30 || theKey > 0x39 )
  276.           { SysBeep( 1 );
  277.             SetPort( temp );
  278.             result = true;
  279.           }
  280.           break;
  281.       }
  282.     }
  283.   }
  284.   else if( myDialogEvent->what == mouseDown )
  285.   { Point mouseLoc;
  286.     short newChoice;
  287.     mouseLoc = ( myDialogEvent->where );
  288.     GlobalToLocal( &mouseLoc );
  289.     switch( newChoice = FindDItem( esd, mouseLoc ) + 1 )
  290.     { case esdFont1St:
  291.       case esdFont1Pu:
  292.         InvertRect( &promptBox1 );
  293.         newChoice = doPop( esd, popMenu1, popUpBox1, popMenuID1, fontChoice1 );
  294.         InvertRect( &promptBox1 );
  295.         if( newChoice != 0 )
  296.         { fontChoice1 = newChoice;
  297.           DrawPopUp1( esd, esdFont1Pu );
  298.           *theDialogItem = esdFont1Pu;
  299.           SetPort( temp );
  300.           result = true;
  301.         }
  302.         break;
  303.       case esdFont2St:
  304.       case esdFont2Pu:
  305.         InvertRect( &promptBox2 );
  306.         newChoice = doPop( esd, popMenu2, popUpBox2, popMenuID2, fontChoice2 );
  307.         InvertRect( &promptBox2 );
  308.         if( newChoice != 0 )
  309.         { fontChoice2 = newChoice;
  310.           DrawPopUp2( esd, esdFont2Pu );
  311.           *theDialogItem = esdFont2Pu;
  312.           SetPort( temp );
  313.           result = true;
  314.         }
  315.         break;
  316.       /* case esdSize2St:  not for size menu!? */
  317.       case esdSize1Pu:
  318.           SelIText( esd, esdSize1Et, 0, 32767 );
  319.           preSize1( esd );
  320.         newChoice = doPop( esd, popMenu3, popUpBox3, popMenuID3, sizeChoice3 );
  321.         if( newChoice != 0 )
  322.         { sizeChoice3 = newChoice;
  323.           DrawPopUpSz( esd, esdSize1Pu );
  324.           *theDialogItem = esdSize1Pu;
  325.           SetPort( temp );
  326.           result = true;
  327.         }
  328.         break;
  329.       /* case esdSize2St:  not for size menu!? */
  330.       case esdSize2Pu:
  331.           SelIText( esd, esdSize2Et, 0, 32767 );
  332.           preSize2( esd );
  333.         newChoice = doPop( esd, popMenu4, popUpBox4, popMenuID4, sizeChoice4 );
  334.         if( newChoice != 0 )
  335.         { sizeChoice4 = newChoice;
  336.           DrawPopUpSz( esd, esdSize2Pu );
  337.           *theDialogItem = esdSize2Pu;
  338.           SetPort( temp );
  339.           result = true;
  340.         }
  341.         break;
  342.     }
  343.   }
  344.   return( result );
  345. }
  346.  
  347. static void check( DialogPtr dbox, short item, Boolean mark )
  348. { ControlHandle hC;
  349.   short itemtype;
  350.   Rect itemrect;    
  351.   GetDItem( dbox, item, &itemtype, (Handle)&hC, &itemrect);
  352.   SetCtlValue( hC, mark );
  353. }
  354.  
  355. static void checks( DialogPtr dbox, short style, short offs )
  356. {
  357.   check( dbox, esdBold1Cb + offs, ( style & bold ) ? 1 : 0 );
  358.   check( dbox, esdItal1Cb + offs, ( style & italic ) ? 1 : 0 );
  359.   check( dbox, esdUndr1Cb + offs, ( style & underline ) ? 1 : 0 );
  360.   check( dbox, esdCond1Cb + offs, ( style & condense ) ? 1 : 0 );
  361.   check( dbox, esdExpd1Cb + offs, ( style & extend ) ? 1 : 0 );
  362.   /*
  363.   check( dbox, esdInvr1Cb + offs, ( style & bold ) ? 1 : 0 );
  364.   */
  365. }
  366.  
  367. short checklist[] = { bold, italic, condense, underline, 0x80, extend };
  368.  
  369. static short findFontItem( MenuHandle hM, short fontNum )
  370. { short result = 1;
  371.   short i, fn;
  372.   Str255 tStr;
  373.   for( i = CountMItems( hM ); i > 0; i-- )
  374.   { GetItem( hM, i, tStr );
  375.     GetFNum( tStr, &fn );
  376.     if( fn == fontNum ) return i;
  377.     if( fn == 0 ) result = i;
  378.   }
  379.   return result;
  380. }
  381.  
  382. /* get the item's rect & set the procPtr */
  383. static void initUserItem( DialogPtr esd, short item, Rect *pRect, ProcPtr pProc )
  384. { short tempItem;
  385.   Handle tempHandle;
  386.   GetDItem( esd, item, &tempItem, &tempHandle, pRect );
  387.   SetDItem( esd, item, tempItem, (Handle)pProc, pRect );
  388. }
  389.  
  390. static void hosePops( void )
  391. {
  392.   if( popMenu1 ) DisposHandle( popMenu1 );
  393.   popMenu1 = 0;
  394.   if( popMenu2 ) DisposHandle( popMenu2 );
  395.   popMenu2 = 0;
  396.   if( popMenu3 ) DisposHandle( popMenu3 );
  397.   popMenu3 = 0;
  398.   if( popMenu4 ) DisposHandle( popMenu4 );
  399.   popMenu4 = 0;
  400. }
  401.  
  402. static void initPops( DialogPtr esd )
  403. { Str255 tStr;
  404.   short tempItem;
  405.   Rect tempRect;
  406.   Handle tempHandle;
  407.  
  408.   hosePops();
  409.   
  410.   SetPort( esd );
  411.   
  412.   popMenu1 = NewMenu( popMenuID1, "" );
  413.   AddResMenu( popMenu1, 'FONT' );
  414.   fontChoice1 = findFontItem( popMenu1, tsNewPri.tsFont );
  415.   SetItemMark( popMenu1, fontChoice1, checkMark );
  416.   InvalRect( &popUpBox1 );
  417.     
  418.   popMenu2 = NewMenu( popMenuID2, "" );
  419.   AddResMenu( popMenu2, 'FONT' );
  420.   fontChoice2 = findFontItem( popMenu2, tsNewAlt.tsFont );
  421.   SetItemMark( popMenu2, fontChoice2, checkMark );
  422.   InvalRect( &popUpBox2 );
  423.   
  424.   popMenu3 = sizeMenu( popMenuID3, &sizeChoice3, tsNewPri.tsFont, tsNewPri.tsSize );
  425.   doSize1( esd );
  426.  
  427.   popMenu4 = sizeMenu( popMenuID4, &sizeChoice4, tsNewAlt.tsFont, tsNewAlt.tsSize );
  428.   doSize2( esd );
  429.   
  430.   checks( esd, tsNewPri.tsFace,  0 );
  431.   checks( esd, tsNewAlt.tsFace, 10 );
  432.   
  433.   NumToString( (long )tabsNew, tStr );
  434.   GetDItem( esd, esdTabsEt, &tempItem, &tempHandle, &tempRect );
  435.   SetIText( tempHandle, tStr );
  436.   SelIText( esd, esdTabsEt, 0, 32767 );
  437.   
  438.   NumToString( (long )wrapNew, tStr );
  439.   GetDItem( esd, esdWrapEt, &tempItem, &tempHandle, &tempRect );
  440.   SetIText( tempHandle, tStr );
  441.   SelIText( esd, esdWrapEt, 0, 32767 );
  442.  
  443.   check( esd, esdAutoInd, autoIndNew );
  444. }  
  445.  
  446. void eStyleDlg( eRec **hE /* , TextStyle *pri, TextStyle *alt */ )
  447. { DialogPtr esd = NULL;
  448.   short hitItem = 0;
  449.   short tempItem;
  450.   Rect tempRect;
  451.   Handle tempHandle;
  452.   Boolean tBool;
  453.   long tmp1, tmp2, tmp3;
  454.   
  455.   tsNewPri = (**hE).style[0];
  456.   tsNewAlt = (**hE).style[1];
  457.   tabsNew = (**hE).tabStops;
  458.   wrapNew = (**hE).wrap;
  459.   autoIndNew = (**hE).autoInd;
  460.  
  461.   /* Get a dialog box, and set up our useritems */
  462.   esd = GetNewDialog( esdID, NULL, (WindowPtr)(-1) );
  463.         
  464.   /* Find out where our useritems are, and set their item handles to be
  465.      a pointer to our popup-drawing or other special procedure */
  466.   GetDItem( esd, esdFont1St, &tempItem, &tempHandle, &promptBox1 ); /* get the title rect */
  467.   initUserItem( esd, esdFont1Pu, &popUpBox1, DrawPopUp1 );
  468.   GetDItem( esd, esdFont2St, &tempItem, &tempHandle, &promptBox2 ); /* get the title rect */
  469.   initUserItem( esd, esdFont2Pu, &popUpBox2, DrawPopUp2 );
  470.   initUserItem( esd, esdSize1Pu, &popUpBox3, DrawPopUpSz );
  471.   initUserItem( esd, esdSize2Pu, &popUpBox4, DrawPopUpSz );
  472.   initUserItem( esd, esdOutline1, &tempRect, Outliner );
  473.   initUserItem( esd, esdOutline2, &tempRect, Outliner );
  474.   initUserItem( esd, esdOutline3, &tempRect, Outliner );
  475.  
  476.   GetDItem( esd, esdOK,&tempItem, &tempHandle, &tempRect ); /* get the OK button's rect */
  477.   InsetRect( &tempRect, -4, -4);
  478.   SetDItem( esd, esdOKring, userItem+itemDisable, (Handle)BorderDefault, &tempRect);
  479.  
  480.   /* Get two menus containing the current set of fonts */
  481.   /* and two menus containing their corresponding sizes */
  482.   initPops( esd );
  483.   
  484.   check( esd, esdThisCb, 1 );
  485.   check( esd, esdPrefCb, 0 );    /* defaulted to off  --  16Jul92  e  */
  486.     
  487.   ShowWindow( (WindowPtr)esd );
  488.   DrawDialog( esd );
  489.   do
  490.   { ModalDialog( (ModalFilterProcPtr)filterIt, &hitItem );
  491.     switch ( hitItem )
  492.     { case esdFont1Pu:
  493.         doFont1( );
  494.         break;
  495.       case esdFont2Pu:
  496.         doFont2( );
  497.         break;
  498.       case esdSize1Pu:
  499.           doSize1( esd );
  500.         break;
  501.       case esdSize2Pu:
  502.           doSize2( esd );
  503.         break;
  504.       case esdBold1Cb:
  505.       case esdItal1Cb:
  506.       case esdCond1Cb:
  507.       case esdUndr1Cb:
  508.       case esdInvr1Cb:
  509.       case esdExpd1Cb:
  510.         GetDItem( esd, hitItem, &tempItem, &tempHandle, &tempRect);
  511.         tempItem = GetCtlValue( (ControlHandle )tempHandle ) ^ 1;
  512.         if( tempItem == 0 )
  513.           tsNewPri.tsFace &= ~checklist[hitItem-esdBold1Cb];
  514.         else
  515.           tsNewPri.tsFace |=  checklist[hitItem-esdBold1Cb];
  516.         SetCtlValue( (ControlHandle )tempHandle, tempItem);
  517.         break;
  518.       case esdBold2Cb:
  519.       case esdItal2Cb:
  520.       case esdCond2Cb:
  521.       case esdUndr2Cb:
  522.       case esdInvr2Cb:
  523.       case esdExpd2Cb:
  524.         GetDItem( esd, hitItem, &tempItem, &tempHandle, &tempRect);
  525.         tempItem = GetCtlValue( (ControlHandle )tempHandle ) ^ 1;
  526.         if( tempItem == 0 )
  527.           tsNewAlt.tsFace &= ~checklist[hitItem-esdBold2Cb];
  528.         else
  529.           tsNewAlt.tsFace |=  checklist[hitItem-esdBold2Cb];
  530.         SetCtlValue( (ControlHandle )tempHandle, tempItem);
  531.         break;
  532.       case esdThisCb:
  533.       case esdPrefCb:
  534.       case esdAutoInd:
  535.         GetDItem( esd, hitItem, &tempItem, &tempHandle, &tempRect);
  536.         tempItem = GetCtlValue( (ControlHandle )tempHandle ) ^ 1;
  537.         SetCtlValue( (ControlHandle )tempHandle, tempItem);
  538.         break;
  539.       case esdThisBt:
  540.         tsNewPri   = (**hE).style[0];
  541.         tsNewAlt   = (**hE).style[1];
  542.         tabsNew    = (**hE).tabStops;
  543.         wrapNew    = (**hE).wrap;
  544.         autoIndNew = (**hE).autoInd;
  545.         initPops( esd );
  546.         break;
  547.       case esdPrefBt:
  548.         tsNewPri   = prefStylNormal;
  549.         tsNewAlt   = prefStylHilite;
  550.         tabsNew    = prefTabs;
  551.         wrapNew    = prefWrap;
  552.         autoIndNew = prefAutoInd;
  553.         initPops( esd );
  554.         break;
  555.       case esdDfltBt:
  556.         tsNewPri   = dfltStylNormal;
  557.         tsNewAlt   = dfltStylHilite;
  558.         tabsNew    = dfltTabs;
  559.         wrapNew    = dfltWrap;
  560.         autoIndNew = dfltAutoInd;
  561.         initPops( esd );
  562.         break;
  563.     }
  564.   } while ( hitItem != esdOK && hitItem != esdCancel );
  565.   
  566.   if( hitItem == esdOK )
  567.   { tsNewPri.tsSize = etToNum( esd, esdSize1Et );
  568.     tsNewAlt.tsSize = etToNum( esd, esdSize2Et );
  569.     tmp1 = etToNum( esd, esdTabsEt );
  570.     tmp2 = etToNum( esd, esdWrapEt );
  571.     GetDItem( esd, esdAutoInd, &tempItem, &tempHandle, &tempRect);
  572.     tmp3 = GetCtlValue( (ControlHandle )tempHandle );
  573.     GetDItem( esd, esdThisCb, &tempItem, &tempHandle, &tempRect);
  574.     if( GetCtlValue( (ControlHandle )tempHandle ) )
  575.     { if( (**hE).tabStops != tmp1 )
  576.       { eTeSetTabStop( hE, (short )tmp1 );
  577.       }
  578.       if( (**hE).wrap != tmp2 )
  579.       { eTeSetWrap( hE, (short )tmp2 );
  580.       }
  581.       (**hE).autoInd = tmp3;
  582.       if(    tsNewPri.tsFont != (**hE).style[0].tsFont
  583.           || tsNewPri.tsSize != (**hE).style[0].tsSize
  584.           || tsNewPri.tsFace != (**hE).style[0].tsFace
  585.           || tsNewAlt.tsFont != (**hE).style[1].tsFont
  586.           || tsNewAlt.tsSize != (**hE).style[1].tsSize
  587.           || tsNewAlt.tsFace != (**hE).style[1].tsFace
  588.         )
  589.       { eTeSetStyles( hE, &tsNewPri, &tsNewAlt );
  590.       }
  591.     }
  592.     GetDItem( esd, esdPrefCb, &tempItem, &tempHandle, &tempRect);
  593.     if( GetCtlValue( (ControlHandle )tempHandle ) )
  594.     { prefStylNormal = tsNewPri;
  595.       prefStylHilite = tsNewAlt;
  596.       prefTabs    = (short )tmp1;
  597.       prefWrap    = (short )tmp2;
  598.       prefAutoInd = (short )tmp3;
  599.       savePrefs( PREFS_FILENAME );  /*  16Jul92  e  */
  600.     }
  601.   }
  602.   hosePops();
  603.   if( esd ) DisposDialog( esd );
  604. }
  605.  
  606. /* end of os_mac_eStyle.c */
  607.